home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Media Design Review 1999
/
Interactive Media Design Review 1999.iso
/
pc
/
Demos
/
Bombardier_PC
/
DATACH.CST
/
00079_Script_79
< prev
next >
Wrap
Text File
|
1999-03-07
|
11KB
|
306 lines
-- database routines
--
-- chris howell
--
global DBRECORD
global DBHANDLE
global qdHandle
global rsHandle
--
-- Bar Chart routines - for hourly operating costs
on drawmainbars
global OBmisc, OBapu, OBengine, OBair, OBfuel, OBtotal
global OBCmisc, OBCapu, OBCengine, OBCair, OBCfuel, OBCtotal
-- set totalmain = OBmisc + OBapu + OBengine + OBair + OBfuel
-- set totalcomp = OBCmisc + OBCapu + OBCengine + OBCair + OBCfuel
set totalmain = OBtotal
set totalcomp = OBctotal
if totalcomp > totalmain then
set totalmain = totalcomp
end if
-- get framing
-- set chartrect_top = the top of sprite 22
-- set chartrect_bottom = the bottom of sprite 22
-- set c_left = the left of sprite 22
-- -- set c_right = the right of sprite 22
-- set c_right = c_left + 75
set chartrect_top = 230
set chartrect_bottom = 413
set c_left = 304
-- set c_right = the right of sprite 22
set c_right = c_left + 75
set current_bottom = chartrect_bottom
-- calculate relative bar sizes and positions
set xxtop = (((1.0 * chartrect_bottom - chartrect_top) / totalmain)¼
* OBfuel)
set xtop = chartrect_bottom - xxtop
set the rect of sprite 10 = rect(c_left,xtop,c_right,current_bottom)
set current_bottom = xtop
set xxtop = (((1.0 * chartrect_bottom - chartrect_top) / totalmain)¼
* OBair)
set xtop = current_bottom - xxtop
set the rect of sprite 11 = rect(c_left,xtop,c_right,current_bottom)
set current_bottom = xtop
set xxtop = (((1.0 * chartrect_bottom - chartrect_top) / totalmain)¼
* OBengine)
set xtop = current_bottom - xxtop
set the rect of sprite 12 = rect(c_left,xtop,c_right,current_bottom)
set current_bottom = xtop
set xxtop = (((1.0 * chartrect_bottom - chartrect_top) / totalmain)¼
* OBapu)
set xtop = current_bottom - xxtop
set the rect of sprite 13 = rect(c_left,xtop,c_right,current_bottom)
set current_bottom = xtop
set xxtop = (((1.0 * chartrect_bottom - chartrect_top) / totalmain)¼
* OBmisc)
set xtop = current_bottom - xxtop
set the rect of sprite 14 = rect(c_left,xtop,c_right,current_bottom)
set current_bottom = xtop
updatestage
end
on drawcompbars
global OBmisc, OBapu, OBengine, OBair, OBfuel
global OBCmisc, OBCapu, OBCengine, OBCair, OBCfuel, OBtotal, OBCtotal
repeat with i = 34 to 38.
puppetsprite i, false
set the visible of sprite i = true
end repeat
updatestage
set totalmain = OBtotal
set totalcomp = OBctotal
if totalcomp > totalmain then
set totalmain = totalcomp
end if
-- get framing
set chartrect_top = 230
set chartrect_bottom = 413
-- set c_left = the left of sprite 22
set c_right = 495
set c_left = 495 - 75
-- set chartrect_top = the top of sprite 22
-- set chartrect_bottom = the bottom of sprite 22
-- -- set c_left = the left of sprite 22
-- set c_right = the right of sprite 22
-- set c_left = c_right - 75
-- calculate relative bar sizes and positions
set current_bottom = chartrect_bottom
set xxtop = (((1.0 * chartrect_bottom - chartrect_top) / totalmain)¼
* OBCfuel)
set xtop = chartrect_bottom - xxtop
set the rect of sprite 15 = rect(c_left,xtop,c_right,current_bottom)
set current_bottom = xtop
set xxtop = (((1.0 * chartrect_bottom - chartrect_top) / totalmain)¼
* OBCair)
set xtop = current_bottom - xxtop
set the rect of sprite 16 = rect(c_left,xtop,c_right,current_bottom)
set current_bottom = xtop
set xxtop = (((1.0 * chartrect_bottom - chartrect_top) / totalmain)¼
* OBCengine)
set xtop = current_bottom - xxtop
set the rect of sprite 17 = rect(c_left,xtop,c_right,current_bottom)
set current_bottom = xtop
set xxtop = (((1.0 * chartrect_bottom - chartrect_top) / totalmain)¼
* OBCapu)
set xtop = current_bottom - xxtop
set the rect of sprite 18 = rect(c_left,xtop,c_right,current_bottom)
set current_bottom = xtop
set xxtop = (((1.0 * chartrect_bottom - chartrect_top) / totalmain)¼
* OBCmisc)
set xtop = current_bottom - xxtop
set the rect of sprite 19 = rect(c_left,xtop,c_right,current_bottom)
set current_bottom = xtop
updatestage
end
on getmainvalues
global default_labor, default_fuel, currentplane
set default_labor = value(losemoney(the text of member "defaultLabor"))
set default_fuel = value(losemoney(the text of member "defaultFuel"))
getmainbars(currentplane, 0)
end
on mainbars
global default_labor, default_fuel, currentplane
watchcursor()
set default_labor = value(losemoney(the text of member "defaultLabor"))
set default_fuel = value(losemoney(the text of member "defaultFuel"))
getmainbars(currentplane, 0)
drawmainbars
arrowcursor()
end
on compbars airplanename
global default_labor, default_fuel
watchcursor()
if ((airplanename = "No Competitor") or (length(airplanename)<4)) or ¼
(airplanename = "NONE") then
set the text of member "disPlane" to "No Competitor"
set the text of member "achplanename" = " "
go to "Hourly costs"
updatestage
else
set the text of member "disPlane" to airplanename
set the text of member "achplanename" = airplanename
set outplane = airplanename
set default_labor = value(losemoney(the text of member "defaultLabor"))
set default_fuel = value(losemoney(the text of member "defaultFuel"))
getmainbars(outplane, 1)
drawmainbars
drawcompbars
end if
arrowcursor()
end
-- losemoney
-- remove $ from stringtoparse
on losemoney stringtoparse
set icx = offset("$", stringtoparse)
if icx = 0 then
nothing
else
delete char icx of stringtoparse
end if
set icx = offset(" ", stringtoparse)
if icx = 0 then
nothing
else
delete char icx of stringtoparse
end if
return stringtoparse
end
-- fill data for bar graphs
on getmainbars dataplanename, mainbarflag
global OBmisc, OBapu, OBengine, OBair, OBfuel
global OBCmisc, OBCapu, OBCengine, OBCair, OBCfuel, OBtotal, OBCtotal
global default_labor, default_fuel, currentplane
set default_labor = value(losemoney(the text of field "defaultlabor"))
set default_fuel = value(losemoney(the text of field "defaultfuel"))
set ochours = the text of field "bar_hours"
set ocregion = the text of field "bar_region"
set notconk = false
set dp = the text of field "disPlane"
if ((length(dp)>4) and (dp<>"No Competitor")) then
set notconk = TRUE
set the text of field "bar_hours" = "Conklin"
set ochours = "Conklin"
end if
if (ochours = "Conklin") then
set qdHandle =DGQDOpen("Operating_CostVals_Conklin",dbHandle)
else
-- not the default hours entered in popup
set qdHandle =DGQDOpen("Operating_CostVals",dbHandle)
if DGQDsetParameterValue("Hours", ochours, qdhandle) = "#ERROR#" then
put "p:"&&GetLastDGError()
end if
end if
if qdHandle="#ERROR" then
alert "Error:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Bomb plane", currentplane, qdhandle) = "#ERROR#" then
put "p:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Model", dataplanename, qdhandle) = "#ERROR#" then
put "p:"&&GetLastDGError()
end if
if DGQDsetParameterValue("Region Value", ocregion, qdhandle) = "#ERROR#" then
put "p:"&&GetLastDGError()
end if
set rsHandle=DGQDCreateRS(qdHandle)
if rsHandle = "#ERROR#" then
alert "Bar DB Error"
else
-- put DGRSGetRecordCount(rsHandle)&&"counts"
-- get data
set landfees = DGRSGetFieldValuech("Landing Fees", rshandle)
set parkfees = DGRSGetFieldValuech("Parking Fees", rshandle)
set passserv = DGRSGetFieldValuech("Passengers Service", rshandle)
set tan = DGRSGetFieldValuech("Terminal Air Navigation", rshandle)
set ran = DGRSGetFieldValuech("Route Air Navigation", rshandle)
set crew = DGRSGetFieldValuech("Crew Expenses", rshandle)
set supplies = DGRSGetFieldValuech("Small Supplies and Catering", rshandle)
set smartparts = DGRSGetFieldValuech("Smart-Parts", rshandle)
set cMisc = landfees + parkfees + passserv + tan + ran + crew + supplies
set cApu = DGRSGetFieldValuech("Apu", rshandle)
set englm = DGRSGetFieldValuech("Engin- LaborMultiplier", rshandle)
set avilm = DGRSGetFieldValuech("Avionics-LaborMultiplier", rshandle)
set airlm = DGRSGetFieldValuech("Airframe-LaborMulitplier", rshandle)
set engparts = DGRSGetFieldValuech("Engine-Parts", rshandle)
set thrustrev = DGRSGetFieldValuech("Thrust Reverser", rshandle)
set cEngine = float(englm * default_labor) + engparts + thrustrev
set cAir = smartparts + float(avilm*default_labor)+float(airlm*default_labor)
set burnrate = chgetfieldvalue("Fuel-burnRate", rshandle)
-- put "air="&&cair"- smartparts="&&smartparts&&"- avilm="&&avilm&&"- airlm="&&airlm
set cfuel = float(burnrate * Default_fuel)
set Oototal = cmisc + capu + cengine + cair + cfuel
if mainbarflag = 0 then
-- main bar
set OBmisc = integer(cmisc)
set OBapu = integer(capu)
set OBengine = integer(cEngine)
set OBair = integer(cAir)
set OBfuel = integer(cFuel)
set OBtotal = integer(oototal)
set the text of field "aaplanename" = dataplanename
set the text of field "aabartotal" = "$" & string(oBtotal)
set the text of field "amisc" = "$" & string(obmisc)
set the text of field "aapu" = "$" & string(obapu)
set the text of field "aengine" = "$" & string(obengine)
set the text of field "aair" = "$" & string(obair)
set the text of field "afuel" = "$" & string(obfuel)
else
-- competitor bar
set OBCmisc = integer(cmisc)
set OBCapu = integer(capu)
set OBCengine = integer(cEngine)
set OBCair = integer(cAir)
set OBCfuel = integer(cFuel)
set OBCtotal = integer(oototal)
set the text of field "acplanename" = dataplanename
set the text of field "acbartotal" = "$" & string(obctotal)
set the text of field "cmisc" = "$" & string(obcmisc)
set the text of field "capu" = "$" & string(obcapu)
set the text of field "cengine" = "$" & string(obcengine)
set the text of field "cair" = "$" & string(obcair)
set the text of field "cfuel" = "$" & string(obcfuel)
end if
if qdHandle > 0 then
if DGQDIsOpen(qdHandle) then
DGQDClose(qdHandle)
end if
set qdHandle = 0
end if
if rsHandle > 0 then
if DGRSIsOpen(rsHandle) then
DGRSClose(rsHandle)
end if
set rsHandle = 0
end if
end if
-- set rsHandle = 0
-- set qdHandle = 0
end
-- get field and error check
on chgetfieldvalue parameterin, recordsethandle
set outch = DGRSGetFieldValue(parameterin,recordsethandle)
if outch = "#ERROR#" then
put parameterin&&GetLastDGError()
end if
-- put parameterin && "=" && outch
return outch
end